package main

import "fmt"

type student struct {
	id int
	name string
	score int
}

func main(){
	a:=student{1,"foo",99}
	//结构体作为函数参数是值传递,形参和实参不是同一个数
	t1(a)
	fmt.Println(a.score)

	t2()
}

func t1(s student){
	fmt.Println(s.name)
	s.score = 98
	fmt.Println(s.score)
}

func t2(){
	//结构体切片作为函数参数是地址传递
	//结构体数组作为函数参数是值传递
	a:=[]student{
		{1,"foo",99},
		{2,"bar",98},
	}
	a=append(a,student{3,"foo1",91})
	fmt.Println("原始a=",a)
	t3(a)
	fmt.Println("原始调用t3函数后a=",a)
}

func t3(a []student){
	a[0].name="yuanlj"
	fmt.Println("t3 a=",a)
}
